package jaux.tank.api.controller;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jaux.tank.bean.vo.front.Ret;
import jaux.tank.bean.vo.front.Rets;
import jaux.tank.service.FaceRecognitionService;

@RestController
@ConditionalOnProperty(prefix = "tank", name = "face-recognition-open", havingValue = "true", matchIfMissing = false)
@RequestMapping("/api/face_recognition")
@Api(tags = "人脸识别web接口")
public class FaceRecognitionController {

	final FaceRecognitionService faceRecognitionService;

    FaceRecognitionController(FaceRecognitionService faceRecognitionService) {
        this.faceRecognitionService = faceRecognitionService;
    }
	
	@GetMapping("/detect")
	@ApiOperation("人脸检测")
	public Ret<Object> detect(@RequestParam String picture,
			@RequestParam @ApiParam(allowableValues = "base64,attachment") String pictureType){
		return Rets.success(faceRecognitionService.detect(picture, pictureType) );
	}
	@GetMapping("/match")
	@ApiOperation("人脸比对")
	public Ret<Object> match(@RequestParam String picture1,
			@RequestParam @ApiParam(allowableValues = "base64,attachment") String pictureType1,
			@RequestParam String picture2,
			@RequestParam @ApiParam(allowableValues = "base64,attachment") String pictureType2){
		return Rets.success(faceRecognitionService.match(picture1, pictureType1, picture2, pictureType2) );
	}
}
